import 'package:cat_eye/base/base_refresh_view_model.dart';
import 'package:cat_eye/bean/home_body_bean.dart';
import 'package:cat_eye/config/url_config.dart';
import 'package:cat_eye/http/http_manager.dart';
import 'package:cat_eye/util/loading_state_widget_util.dart';
import 'package:flutter/material.dart';

/*
* @Package: view_model.find_view_model
* @ClassName: find_follow_view_model
* @Author: szj
* @CreateDate: 8/2/21 10:31 AM
*/
class FindFollowViewModel extends BaseRefreshViewModel {
  List<ItemList> itemList = [];

  String loadMoreUrl;

  @override
  String get httpUrl => UrlConfig.followUrl;

  //上拉刷新需要的数据
  @override
  String get httpLoadMoreUrl => loadMoreUrl;

  void refresh() {
    //下拉刷新时清空数据
    if (itemList.length > 0) {
      itemList.clear();
    }

    //调用父类,请求数据
    super.refresh();
  }

  /*
   *  成功返回数据
   */
  @override
  void successJsonData(dynamic json) {
    var bean = IssueList.fromJson(json);

    //下拉刷新Url
    loadMoreUrl = bean.nextPageUrl;

    //添加所有数据
    itemList.addAll(bean.itemList);
  }
}
